<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="include::head"></head>
<body>
<div class="layui-fluid">
    <!--form表单-->
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="loginAccount" autocomplete="off" disabled class="layui-input layui-disabled" lay-verify="required" th:value="${user.loginAccount}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" name="userName" th:value="${user.userName}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" name="nickname" th:value="${user.nickname}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">年龄</label>
            <div class="layui-input-block">
                <input type="text" name="age" th:value="${user.age}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input type="text" name="mobile" th:value="${user.mobile}"  disabled class="layui-input layui-disabled" autocomplete="off" lay-verify="phone">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="email" th:value="${user.email}" autocomplete="off" class="layui-input" lay-verify="email">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">QQ</label>
            <div class="layui-input-block">
                <input type="text" name="qq" th:value="${user.qq}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <th:block th:each="value : ${diy['sex_type']}">
                    <th:block th:if="${value.dictionaryRoute == user.sex}" >
                        <input  type="radio" name="sex" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                    </th:block>
                    <th:block th:if="${value.dictionaryRoute != user.sex}" >
                        <input  type="radio" name="sex" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                    </th:block>
                </th:block>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <th:block th:each="value : ${diy['state_type']}">
                    <th:block th:if="${value.dictionaryRoute == user.isState}" >
                        <input  type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                    </th:block>
                    <th:block th:if="${value.dictionaryRoute != user.isState}" >
                        <input  type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                    </th:block>
                </th:block>
            </div>
        </div>

        <div class="layui-form-item" id="dept-select">
            <label class="layui-form-label">部门</label>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">个性签名</label>
            <div class="layui-input-block">
                <textarea name="remarks" th:utext="${user.description}" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">角色：</label>
            <div class="layui-input-block">
                <div id="role-tree">loding... ...</div>
            </div>
        </div>
        <input name="userId" th:value="${user.userId}" type="hidden">
        <input id="menuIds" name="menuIds" lay-verify="menuIds" type="hidden">
        <input id="deptId" name="deptId" lay-verify="deptId" type="hidden">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::onload"></div>
<script  th:inline="javascript">
    layui.config({
        base: '/js/layer/module/'//模块存放的目录
    }).use(['areal','form','verify'], function(){
        var form = layui.form,
            verify = layui.verify,
            areal = layui.areal;

        $.tree.initCheckbox("#role-tree",[[${user.roleTree}]]);

        verify.verification("#role-tree");

        areal.init($('#dept-select'),[[${dept}]],[[${userdept}]]);

        // 监听提交
        form.on('submit(edit)', function(data) {
            $.achieve.post("/admin/staff/user/update",data.field,"",true);
            return false;
        });

    });
</script>
</body>
</html>